import Swiper from "https://lib.baomitu.com/Swiper/8.4.4/swiper-bundle.esm.browser.min.js"

fetch("{{BASE_URL}}/api/carouselGroup/get?carouselGroupId=966")
            .then(res => res.json())
            .then(data => {
                console.log(data.result)
                let mainBox = document.querySelector("#swiper1>.swiper-wrapper")
                //遍历所有的数据
                data.result.forEach(item => {
                    mainBox.innerHTML += `
                <div class="swiper-slide">
                    <img data-src="${item.content}" class="swiper-lazy" alt="">
                    <div class="swiper-lazy-preloader"></div>
                </div>
                `;
                })
                var swiper1 = new Swiper('#swiper1', {
                    //分页器
                    pagination: {
                        el: '.swiper-pagination',
                        //开启小圆点切换功能
                        clickable: true,
                    },
                    //自动播放
                    autoplay: {
                        //停留时间
                        delay: 1000,
                        //鼠标移入停止轮播，移出开始自动轮播
                        pauseOnMouseEnter: true,
                        //关闭静止自动播放
                        disableOnInteraction: false,
                    },
                    //开启无缝轮播
                    loop: true,
                    //切换效果
                    effect: 'fade',
                    //开启懒加载
                    lazy: true
                });
            })
            .catch(err => console.log(err))